package com.zhixinhuixue.zsyte.xxx.ui.fragment

import android.os.Bundle
import com.bumptech.glide.Glide
import com.gyf.immersionbar.ImmersionBar
import com.gyf.immersionbar.ktx.immersionBar
import com.zhixinhuixue.zsyte.xxx.R
import com.zhixinhuixue.zsyte.xxx.app.App
import com.zhixinhuixue.zsyte.xxx.app.base.BaseFragment
import com.zhixinhuixue.zsyte.xxx.databinding.FragmentFourBinding
import com.zhixinhuixue.zsyte.xxx.ui.activity.ConfigurationActivity
import com.zhixinhuixue.zsyte.xxx.ui.activity.LoginActivity
import com.zhixinhuixue.zsyte.xxx.ui.activity.PasswordActivity
import com.zhixinhuixue.zsyte.xxx.ui.viewmodel.TestViewModel
import me.hgj.mvvmhelper.ext.setOnclickNoRepeat
import me.hgj.mvvmhelper.ext.showDialogMessage
import me.hgj.mvvmhelper.ext.toStartActivity

/**
 * 作者　: hegaojian
 * 时间　: 2020/11/18
 * 描述　:
 */
class FourFragment : BaseFragment<TestViewModel, FragmentFourBinding>() {

    override val layoutId: Int get() = R.layout.fragment_four

    override fun initView(savedInstanceState: Bundle?) {
        Glide.with(this)
            .load("https://t7.baidu.com/it/u=1956604245,3662848045&fm=193&f=GIF")
            .fitCenter()
            .into(mDataBind.userHeadImg)

        Glide.with(this)
            .load("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic1.zhimg.com%2F50%2Fv2-b8f57a87ccff572c84bea1c0497f999d_r.jpg&refer=http%3A%2F%2Fpic1.zhimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1638246585&t=15d3bcd52dc5ad7a20c0b9faee6f8fa0")
            .fitCenter()
            .into(mDataBind.userHeadImg1)
    }

    override fun onResume() {
        super.onResume()
        immersionBar {
            titleBar(mDataBind.userHeadImg)
        }
    }

    override fun onBindViewClick() {
        setOnclickNoRepeat(mDataBind.logout, mDataBind.password) {
            when (it.id) {


                R.id.password -> {
                    toStartActivity(PasswordActivity::class.java)
                }
                R.id.logout -> {
                    showDialogMessage("是否退出登录？", "温馨提示", "确定", {
                        App.instance.restartApplication()
                    },"取消")

                }
            }
        }
    }
}